package com.wencai.daily;

import com.wencai.util.IOUtils;

import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author wangpan
 * @date 2023/6/9
 */
public class Merge {
    private static String outPath = "D:\\Users\\Administrator\\Desktop\\记录\\";
    private static String indexPath = "D:\\Users\\Administrator\\Desktop\\记录\\所有索引\\";

    public static void main(String[] args) throws IOException {
        File indexDirFile = new File(indexPath);
        String[] list = indexDirFile.list();
        Set<String> lineSet = new HashSet<>();
        for (String fileName : list) {
            if (!fileName.endsWith(".txt")) {
                continue;
            }
            List<String> lines = IOUtils.readFromFile(indexPath + fileName, "gbk");
            for (String line : lines) {
                if (line.startsWith("sz.00") || line.startsWith("sh.60")) {
                    lineSet.add(line);
                }
            }
        }
        StringBuilder builder = new StringBuilder();
        for (String line : lineSet) {
            builder.append(line).append(System.lineSeparator());
        }
        IOUtils.writeFile(outPath + "所有索引.txt", builder.toString(), "gbk");
    }
}
